//
//  NSObject+YLJUserDefaults.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/21.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "NSObject+YLJUserDefaults.h"
#define kSafeString(__string) (__string)?(__string):@""

#define kKey_accountType  @"kKey_accountType"
#define kKey_userId  @"kKey_userId"
#define kKey_userInforData  @"kKey_userInforData"


@implementation NSObject (YLJUserDefaults)
/***************************Object*****************************/

- (void)setObject:(id)aObject forKey:(NSString *)aKey {
    [kUserDefaults setObject:aObject
                       forKey:aKey];
    [kUserDefaults synchronize];
}
- (id)objectForKey:(NSString *)aKey {
    return kSafeString([kUserDefaults objectForKey:aKey]);
}
/***************************NSInteger*****************************/

- (void)setInteger:(NSInteger)aObject forKey:(NSString *)aKey {
    [kUserDefaults setInteger:aObject
                        forKey:aKey];
}
- (NSInteger)integerForKey:(NSString *)aKey {
    return [kUserDefaults integerForKey:aKey];
}
#pragma mark =================== 存储 ===================
//用户类型
-(void)setAccountType:(AccountType)accountType{
    [self setInteger:accountType forKey:kKey_accountType];
}
-(AccountType)accountType{
    return (AccountType)[self integerForKey:kKey_accountType];
}
//用户ID
-(void)setUserId:(NSString *)userId{
    [self setObject:userId forKey:kKey_userId];
}
-(NSString *)userId{
    return [self objectForKey:kKey_userId];
}
//用户信息
-(void)setUserInforData:(NSData *)userInforData{
    [self setObject:userInforData forKey:kKey_userInforData];
}

-(NSData *)userInforData{
    return [self objectForKey:kKey_userInforData];
}


@end
